package org.zachary.creditbusiness.hotel.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping( "/**")               // 所有请求
                .allowedOriginPatterns("*")             // 允许所有域名
                .allowedMethods("GET","POST","PUT","DELETE","OPTIONS")
                .allowedHeaders("*")             // 允许所有头
                .allowCredentials(true)          // 允许携带 Cookie
                .maxAge(3600);                   // 预检结果缓存 1 小时
    }
}
